package com.loyal.loyalerp.mapper;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.loyal.loyalerp.model.GyUserRole;

@Mapper
public interface GyUserRoleMapper {
	
	@Delete("delete from gy_user_role where userid=#{userid} and roleid=#{roleid}")
	int deleteByUserIdAndRoleId(GyUserRole ur);
	
	@Insert("insert into gy_user_role (userid,roleid) value(#{userid},#{roleid})")
	int insertByUserIdAndRoleId(GyUserRole ur);
	
	@Select("select count(*) from gy_user_role where userid=#{userid} and roleid=#{roleid}")
	int selectByUserIdAndRoleId(GyUserRole ur);
	
	int deleteByCode(@Param("usercode") int usercode,@Param("rolecode") int rolecode,@Param("companyid") int companyid);
	
	int selectUserIDByUserCode(int usercode);
	
	GyUserRole selectUserRoleByRoleCode(int rolecode);
	
    int deleteByPrimaryKey(Integer id);

    int insert(GyUserRole record);

    int insertSelective(GyUserRole record);

    GyUserRole selectByPrimaryKey(Integer userRoleID);

    List<GyUserRole> listAll();
    
    int updateByPrimaryKeySelective(GyUserRole record);

    int updateRoleByPK(int id);
    
    int updateByPrimaryKey(GyUserRole record);
    @Delete("delete from gy_user_role where companyId=#{id}")
	int deleteByCompanyId(Integer id);
    @Delete("delete from gy_user_role where UserId=#{id}")
	void deleteByUserId(Integer id);
    @Delete("delete from gy_user_role where RoleId=#{id}")  
	void deleteByRoleId(Integer id);
}